﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Pages_Admin_Misc_ProductImage :NoTheme
{
    string productid;
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Request["id"] == null)
        {
            Response.Write("<script>window.close();</script>");
        }
        else
        {
            productid = Request["id"].ToString();
            UpLoad1.GUID = productid;
        }
    }

    protected void btnsubmit_Click(object sender, EventArgs e)
    {
        try
        {
            string filePath = UpLoad1.FullPath;
            if (string.IsNullOrEmpty(filePath))
            {
                Response.Write("<script> alert('请选择需要上传的文件!') </script>");
                return;
            }
            if (!string.IsNullOrEmpty(filePath) && !string.IsNullOrEmpty(productid))
            {
               
                filePath = filePath.Replace('\\', '/');
                filePath = filePath.Replace("//", "/");
                int flag = (new Tuan.BLL.Products()).UpdateShowImage(int.Parse(productid),filePath);
                if (flag > 0)
                {
                    Response.Write("<script> alert('更新成功');window.close() </script>");
                }
                else
                {
                    Response.Write("<script> alert('未能上传成功，请重新上传！') </script>");
                }
            }
            else
            {
                Response.Write("<script> alert('上传成功,未能正常写入数据库!') </script>");
            }
        }
        catch (Exception ex)
        {
            Response.Write("<script> alert('服务器错误，请稍候上传!') </script>");
        }
    }
}
